/**
 * @Author：ming
 * @Date：2023/10/30 3:31 PM
 * @Filename：Hot141
 */

/**
 * @author ming
 */
public class Hot141 {
    public boolean hasCycle(ListNode head) {
        ListNode fast = head;
        ListNode slow = head;
        while (fast!=null&&slow!=null){
            fast = fast.next;
            if(fast==null){
                return false;
            }
            fast = fast.next;

            slow =slow.next;
            if(slow==null||fast==null){
                return false;
            }
            if(slow==fast){
                return true;
            }
        }

        return false;

    }


}
